package top.malaoshi.webmvc.info;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import top.malaoshi.webmvc.factory.ObjectFactory;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * 封装 bean 的信息
 */
public class ClassInfo {

    /**
     * 指定配置文件
     */
    private PropertySource propertySource;
    /**
     * bean类上的注解，如：@Controller、@RestController、@Service、@Component 等
     */
    private Class componentAnnotation;
    /**
     * @Configuration 注解信息
     */
    private Configuration configurationAnnotation;
    /**
     * bean 的 Class 对象
     */
    private Class clazz;

    /**
     * 创建对象的工厂类
     */
    private ObjectFactory objectFactory;

    /**
     * 存放 FieldInfo 成员变量信息对象
     */
    public List<FieldInfo> fieldInfos = new ArrayList<>();
    /**
     * bean的名字
     */
    private String name;
    /**
     * 排序
     */
    private int order;
    /**
     * @Bean 注解修饰的方法
     */
    private List<MethodInfo> beanAnnotationMethodInfos = new ArrayList<>();
    public Class getClazz() {
        return clazz;
    }

    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Class getComponentAnnotation() {
        return componentAnnotation;
    }

    public void setComponentAnnotation(Class componentAnnotation) {
        this.componentAnnotation = componentAnnotation;
    }

    public void addBeanAnnotationMethodInfo(MethodInfo methodInfo){
        beanAnnotationMethodInfos.add(methodInfo);
    }

    public List<MethodInfo> getBeanAnnotationMethodInfos() {
        return beanAnnotationMethodInfos;
    }



    public ObjectFactory getObjectFactory() {
        return objectFactory;
    }

    public void setObjectFactory(ObjectFactory objectFactory) {
        this.objectFactory = objectFactory;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public Configuration getConfigurationAnnotation() {
        return configurationAnnotation;
    }

    public void setConfigurationAnnotation(Configuration configurationAnnotation) {
        this.configurationAnnotation = configurationAnnotation;
    }
    public void addFieldInfo(FieldInfo fi){
        fieldInfos.add(fi);
    }

    public List<FieldInfo> getFieldInfos() {
        return fieldInfos;
    }

    public void setPropertySource(PropertySource propertySource) {
        this.propertySource = propertySource;
    }


}
